package com.example.controller;

import com.example.aspect.AspectAnnotation;
import com.example.entity.Result;
import com.example.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    /**
     * 添加学生
     *
     * @return
     */
    @AspectAnnotation
    @PostMapping("/addStudent")
    public Result addStudent() {
        // TODO: 添加学生
        String result = studentService.saveStudent();
        return Result.success("addStudent success", result);
    }

    /**
     * 查询单个学生
     *
     * @return
     */
    @GetMapping("getStudentById")
    public Result getStudentById() {
        // TODO: 查询单个学生
        String result = studentService.getStuentById();
        return Result.success("getStudent success", result);
    }

    /**
     * 查询学生列表
     *
     * @return
     */
    @GetMapping("getStudentList")
    public Result getStudentList() {
        // TODO: 查询学生列表
        String result = studentService.getStudentList();
        return Result.success("getStudentList success", result);
    }

    /**
     * 删除学生
     *
     * @return
     */
    @AspectAnnotation
    @DeleteMapping("deleteStudentById")
    public Result deleteStudentById() {
        // TODO: 删除学生
        String result = studentService.deleteStudentById();
        return Result.success("deleteStudentById success", result);
    }

    /**
     * 更新学生
     *
     * @return
     */
    @PutMapping("updateStudent")
    public Result updateStudent() {
        // TODO: 更新学生
        String result = studentService.updateStudent();
        return Result.success("updateStudent success", result);
    }

}
